﻿/*
' DotNetNuke® - http://www.dotnetnuke.com
' Copyright (c) 2002-2009
' by DotNetNuke Corporation
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions 
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
' DEALINGS IN THE SOFTWARE.
*/

using System;
using MbUnit.Framework;
using WatiN.Core;
using DotNetNuke.Tests.UI.WatiN.Common;
using DotNetNuke.Tests.UI.WatiN.WatiNObjects;

namespace DotNetNuke.Tests.UI.WatiN
{
    [TestFixture]
    public class SharedObjectsTests : TestBase
    {

        #region Element Exists Tests
        [Test]
        public void Page_Should_Contain_Logo()
        {
            //Arrange
            WatiNBase basePage = new WatiNBase(WatiNUtil.OpenIEInstance(SiteURL, SilentMode, IETimeOut, AutoCloseIE), SiteURL);

            //Act
            Link logoLink = basePage.LogoLink;

            //Assert
            WatiNAssert.ElementExists<Link>(logoLink);
        }

        [Test]
        public void Page_Should_Contain_Login_Link()
        {
            //Arrange
            WatiNBase basePage = new WatiNBase(WatiNUtil.OpenIEInstance(SiteURL, SilentMode, IETimeOut, AutoCloseIE), SiteURL);

            //Act
            Link loginLink = basePage.LoginLink;

            //Assert
            WatiNAssert.ElementExists<Link>(loginLink);
        }

        [Test]
        public void Page_Should_Contain_Privacy_Link()
        {
            //Arrange
            WatiNBase basePage = new WatiNBase(WatiNUtil.OpenIEInstance(SiteURL, SilentMode, IETimeOut, AutoCloseIE), SiteURL);

            //Act
            Link privacyLink = basePage.PrivacyLink;

            //Assert
            WatiNAssert.ElementExists<Link>(privacyLink);
        }

        [Test]
        public void Page_Should_Contain_Register_Link()
        {
            //Arrange
            WatiNBase basePage = new WatiNBase(WatiNUtil.OpenIEInstance(SiteURL, SilentMode, IETimeOut, AutoCloseIE), SiteURL);

            //Act
            Link registerLink = basePage.RegisterLink;

            //Assert
            WatiNAssert.ElementExists<Link>(registerLink);
        }

        [Test]
        public void Page_Should_Contain_Terms_Link()
        {
            //Arrange
            WatiNBase basePage = new WatiNBase(WatiNUtil.OpenIEInstance(SiteURL, SilentMode, IETimeOut, AutoCloseIE), SiteURL);

            //Act
            Link termsLink = basePage.TermsLink;

            //Assert
            WatiNAssert.ElementExists<Link>(termsLink);
        }

        [Test]
        public void Page_Should_Contain_Copyright_Span()
        {
            //Arrange
            WatiNBase basePage = new WatiNBase(WatiNUtil.OpenIEInstance(SiteURL, SilentMode, IETimeOut, AutoCloseIE), SiteURL);

            //Act
            Span copyrightSpan = basePage.CopyrightSpan;

            //Assert
            WatiNAssert.ElementExists<Span>(copyrightSpan);
        }
        #endregion

        #region Content Tests
        [Test]
        public void Copyright_Text_Should_Be_Current()
        {
            //Arrange
            WatiNBase basePage = new WatiNBase(WatiNUtil.OpenIEInstance(SiteURL, SilentMode, IETimeOut, AutoCloseIE), SiteURL);

            //Act
            Span copyrightSpan = basePage.CopyrightSpan;

            //Assert
            WatiNAssert.ContentContains<Span>(DateTime.Now.Year.ToString(), copyrightSpan);
        }

        [Test]
        public void Copyright_Text_Should_Contain_Company_Name()
        {
            //Arrange
            WatiNBase basePage = new WatiNBase(WatiNUtil.OpenIEInstance(SiteURL, SilentMode, IETimeOut, AutoCloseIE), SiteURL);

            //Act
            Span copyrightSpan = basePage.CopyrightSpan;

            //Assert
            WatiNAssert.ContentContains<Span>("DotNetNuke Corporation", copyrightSpan);
        }
        #endregion

        #region Link Click Tests
        [Test]
        public void LoginLink_Click_Should_Open_Login_Page()
        {
            //Arrange
            WatiNBase basePage = new WatiNBase(WatiNUtil.OpenIEInstance(SiteURL, SilentMode, IETimeOut, AutoCloseIE), SiteURL);
            LoginPage loginPage = new LoginPage(basePage);

            //Act
            basePage.LoginLink.Click();

            //Assert
            WatiNAssert.ElementExists<Div>(loginPage.LoginPanel);
        }

        [Test]
        public void PrivacyLink_Click_Should_Open_Privacy_Page()
        {
            //Arrange
            WatiNBase basePage = new WatiNBase(WatiNUtil.OpenIEInstance(SiteURL, SilentMode, IETimeOut, AutoCloseIE), SiteURL);
            PrivacyPage privacyPage = new PrivacyPage(basePage);

            //Act
            basePage.PrivacyLink.Click();

            //Assert
            WatiNAssert.ElementExists<Span>(privacyPage.PrivacySpan);
        }

        [Test]
        public void TermsLink_Click_Should_Open_Terms_Page()
        {
            //Arrange
            WatiNBase basePage = new WatiNBase(WatiNUtil.OpenIEInstance(SiteURL, SilentMode, IETimeOut, AutoCloseIE), SiteURL);
            TermsOfUsePage termsOfUsePage = new TermsOfUsePage(basePage);

            //Act
            basePage.TermsLink.Click();

            //Assert
            WatiNAssert.ElementExists<Span>(termsOfUsePage.TermsSpan);
        }
        #endregion
    }
}
